package org.ziwei.paipan;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.ziwei.paipan.biao.LiuNianDouJunBiao;
import org.ziwei.paipan.biao.Utils;
import org.ziwei.paipan.biao.ZhiXiZhuXingBiao;
import org.ziwei.paipan.biao.ZiNianDouJunBiao;
import org.ziwei.paipan.var.DiZhi;
import org.ziwei.paipan.var.Sex;
import org.ziwei.paipan.var.StarCode;
import org.ziwei.paipan.var.TianGan;
import org.ziwei.paipan.var.WuXing;
import org.ziwei.paipan.var.YinYang;
/**
 * 命盘基本信息类
 * @param: 阴历生日，性别，流年
 * @author dwt
 *
 */
public class BasicInfo {

	private Date yinLi;  	//阴历生日
	
	private Sex sex;		//性别，F是女，M是男
	
	private int age; 		//阴历年龄

	private DiZhi shiChen;   //出生时辰
	
	private int year;		 //年
	
	private int month;		 //月
	
	private int day;		 //日
	
	private int hour;		 //时
	
	private TianGan tianGan; //生年天干
	
	private DiZhi diZhi;     //生年地支
	
	private YinYang yinYang; //阴阳
	
	private WuXing wuXing;   //五行
	
	private DiZhi daXian;    //大限宫支，当前所在的宫支
	
	private StarCode mingZhu;    //命主
	
	private StarCode shenZhu;    //身主
	
	private TianGan liuNianTianGan;  //流年天干
	
	private DiZhi liuNianDiZhi;      //流年地支

	private DiZhi ziNianDouJun;   //子年斗君所在地支
	
	private DiZhi liuNianDouJun;  //流年斗君所在地支
	
	public BasicInfo(Date birthday, Sex sex, int curYear){
		init(birthday, sex, curYear);
	}
	
	private void init(Date birthday, Sex sex, int curYear){
		this.yinLi = birthday;
		this.sex = sex;
		
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(birthday);
		this.year = calendar.get(Calendar.YEAR);  
		this.month = calendar.get(Calendar.MONTH);  
		this.day = calendar.get(Calendar.DAY_OF_MONTH);  
		this.hour = calendar.get(Calendar.HOUR_OF_DAY); 
		this.age = curYear - year + 1;
		
		this.shiChen = Utils.convertToShiChen(hour);
		
		this.tianGan = Utils.convertToTianGan(year);
		this.diZhi = Utils.convertToDiZhi(year);
		this.liuNianTianGan = Utils.convertToTianGan(curYear);
		this.liuNianDiZhi = Utils.convertToDiZhi(curYear);
		this.yinYang = Utils.convertToYinYang(year);
		
		this.mingZhu = ZhiXiZhuXingBiao.anMingZhu(this.diZhi);
		this.shenZhu = ZhiXiZhuXingBiao.anShenZhu(this.diZhi);
		
		//安子年斗君
		this.ziNianDouJun = ZiNianDouJunBiao.anZiNianDouJun(month, shiChen);
		//安流年斗君
		this.liuNianDouJun = LiuNianDouJunBiao.anLiuNianDouJun(liuNianDiZhi, ziNianDouJun);
	}
	
	public String toString(){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd mm:HH:ss");
		String str = "阴历生日:"+df.format(yinLi)+"\n" +
					 "年龄:"+age+"\n" + 
					 "天干:"+tianGan.getName()+"\n" + 
					 "地支:"+diZhi.getName()+"\n" + 
					 "时辰:"+shiChen.getName()+"\n" + 
					 "性别:"+sex.getName()+"\n" + 
		 			 "阴阳:"+yinYang.getName()+"\n" +
					 "五行局:"+wuXing.getName()+wuXing.getNum()+"局\n" + 
					 "命主:"+mingZhu.getName()+"\n" + 
					 "身主:"+shenZhu.getName()+"\n" +
					 "大限:"+daXian.getName()+"\n";
		return str;
	}
	
	public Date getYinLi() {
		return yinLi;
	}

	public void setYinLi(Date yinLi) {
		this.yinLi = yinLi;
	}

	public TianGan getTianGan() {
		return tianGan;
	}

	public void setTianGan(TianGan tianGan) {
		this.tianGan = tianGan;
	}

	public DiZhi getDiZhi() {
		return diZhi;
	}

	public void setDiZhi(DiZhi diZhi) {
		this.diZhi = diZhi;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Sex getSex() {
		return sex;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}

	public YinYang getYinYang() {
		return yinYang;
	}

	public void setYinYang(YinYang yinYang) {
		this.yinYang = yinYang;
	}

	public WuXing getWuXing() {
		return wuXing;
	}

	public void setWuXing(WuXing wuXing) {
		this.wuXing = wuXing;
	}

	public DiZhi getDaXian() {
		return daXian;
	}

	public void setDaXian(DiZhi daXian) {
		this.daXian = daXian;
	}

	public StarCode getMingZhu() {
		return mingZhu;
	}

	public void setMingZhu(StarCode mingZhu) {
		this.mingZhu = mingZhu;
	}

	public StarCode getShenZhu() {
		return shenZhu;
	}

	public void setShenZhu(StarCode shenZhu) {
		this.shenZhu = shenZhu;
	}

	public DiZhi getShiChen() {
		return shiChen;
	}

	public void setShiChen(DiZhi shiChen) {
		this.shiChen = shiChen;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getHour() {
		return hour;
	}

	public void setHour(int hour) {
		this.hour = hour;
	}

	public DiZhi getZiNianDouJun() {
		return ziNianDouJun;
	}

	public void setZiNianDouJun(DiZhi ziNianDouJun) {
		this.ziNianDouJun = ziNianDouJun;
	}

	public TianGan getLiuNianTianGan() {
		return liuNianTianGan;
	}

	public void setLiuNianTianGan(TianGan liuNianTianGan) {
		this.liuNianTianGan = liuNianTianGan;
	}

	public DiZhi getLiuNianDiZhi() {
		return liuNianDiZhi;
	}

	public void setLiuNianDiZhi(DiZhi liuNianDiZhi) {
		this.liuNianDiZhi = liuNianDiZhi;
	}

	public DiZhi getLiuNianDouJun() {
		return liuNianDouJun;
	}

	public void setLiuNianDouJun(DiZhi liuNianDouJun) {
		this.liuNianDouJun = liuNianDouJun;
	}
	
}
